<template>
  <div>
    <div class='components-input-demo-presuffix'>
      <j-modal
        :visible.sync='visible'
        :width='800'
        :title='title'
      >
        <template>
          <div class='table-page-search-wrapper'>
            <a-form layout='inline'>
              <a-row :gutter='24'>
                <a-col :span='12'>
                  <a-form-model-item label='年级' prop='queryParam.gradeId'>
                    <j-dict-select-tag @change='chgGradeId' v-model='queryParam.gradeId' placeholder='请选择年级'
                                       dictCode='cou_grade,grade_name,id,tenant_id  is not null order by  grade_order' />
                  </a-form-model-item>
                </a-col>
                <a-col :span='12'>
                  <a-form-model-item label='考试' prop='queryParam.examinationId'>
                    <j-dict-select-tag @change='chgExaminationId' v-model='queryParam.examinationId'
                                       placeholder='请选择考试'
                                       :dictCode='queryParamSelect.examinationIdSelect' />
                  </a-form-model-item>
                </a-col>
              </a-row>

              <a-row :gutter='24'>
                <a-col :span='12'>
                  <a-form-model-item label='班级' prop='queryParam.classId'>
                    <j-multi-select-tag v-model='queryParam.classId' placeholder='请选择班级'
                                        :dictCode='queryParamSelect.classIdSelect' />
                  </a-form-model-item>
                </a-col>
                <div v-show='isMulti'>
                  <a-col :span='12'>
                    <a-form-item label='试卷'>
                      <j-multi-select-tag v-model='queryParam.examinationPaperId'
                                          placeholder='请选择试卷' :dictCode='queryParamSelect.examinationPaperIdSelect' />
                    </a-form-item>
                  </a-col>
                </div>
                <div v-show='!isMulti'>
                  <a-col :span='12'>
                    <a-form-item label='试卷'>
                      <j-dict-select-tag v-model='queryParam.examinationPaperId'
                                         placeholder='请选择试卷' :dictCode='queryParamSelect.examinationPaperIdSelect' />
                    </a-form-item>
                  </a-col>
                </div>
              </a-row>

            </a-form>
          </div>
        </template>
        <template slot='footer'>
          <span style='font-size: 0.1px;color: crimson; !important;'>{{ msg }}</span>
          <a-button @click='closeMessage'>关闭</a-button>
          <a-button key='submit' type='primary'
                    @click="handleSubmit">提交
          </a-button>
        </template>
      </j-modal>

    </div>
  </div>
</template>

<script>

import { downFile, getAction, postAction } from '@api/manage'

export default {
  name: 'JSelectClassExaminationSubmit',
  components: {},
  props: {
    title: {
      type: String,
      default: '',
      required: false
    },
    isMulti: {
      type: Boolean,
      default: true
    },
    msg: {
      type: String,
      default: ''
    }

  },
  data() {
    return {
      showText: '',
      avalid: false,
      visible: false,
      queryParam: {},
      //查询条件联动部分定义
      queryParamSelect: {},
      newDate: '',
      oldDate: '',
      jCheckboxOptions: [
        { label: '全校', value: '-1' }
      ]
    }
  },
  computed: {},
  watch: {},
  created() {
  },
  mounted() {
  },
  methods: {
    openModal() {
      if (this.visible === false) {
        this.visible = true
      }
      if (this.avalid === false) {
        this.avalid = true
      }
    },
    //更改年级-->选择考试，选择班级
    chgGradeId() {
      if (this.queryParam.gradeId) { //判断不为空
        this.queryParamSelect.examinationIdSelect = 'ach_examination,examination_name,id,del_flag  =0 and iz_open  =1 and grade_id=\'' + this.queryParam.gradeId + '\' order by create_time  desc'
        this.queryParamSelect.classIdSelect = 'cou_class,class_name,id,class_iz_open  =1 and class_iz_delete  = 0 and grade_code=\'' + this.queryParam.gradeId + '\' order by  class_order'
      }
    },
    //更改考试-->选择试卷
    chgExaminationId() {
      if (this.queryParam.examinationId) {
        this.queryParamSelect.examinationPaperIdSelect = 'ach_examination_paper aep,aep.examination_paper_name,aep.id,aep.iz_open =1 and aep.del_flag =0 and aep.examination_id =\'' + this.queryParam.examinationId + '\'  order by aep.examination_paper_name'
      }
    },
    handleSubmit() {
      if (this.visible === true) {
        this.visible = false
      }
      if (this.avalid === true) {
        this.avalid = false
      }
      this.$emit('closeExaminationSubmit', {msg: 'submit',data: this.queryParam})
    },
    handleReleaseCancel() {
      this.courseReleaseVisible = false
    },
    showReleaseModal() {
      this.courseReleaseVisible = true
    },
    closeMessage() {
      if (this.visible === true) {
        this.visible = false
      }
      if (this.avalid === true) {
        this.avalid = false
      }
      this.$emit('closeExaminationSubmit', {msg: 'close'})
    },
    changeValue() {
      this.queryParam.gradeId = null
      this.queryParam.classId = null
    }
  }
}
</script>
<style scoped>
.components-input-demo-presuffix .anticon-close-circle {
  cursor: pointer;
  color: #ccc;
  transition: color 0.3s;
  font-size: 12px;
}

.components-input-demo-presuffix .anticon-close-circle:hover {
  color: #f5222d;
}

.components-input-demo-presuffix .anticon-close-circle:active {
  color: #666;
}
</style>